import request from '@/utils/request'
// import qs from 'qs'

// 获取连接信息
export function getConnectArray (params) {
  var data = fromData(params)
  return request({
    url: '/connect/getConnectArray',
    method: 'post',
    data
  })
}

// 增加连接
export function addConnect (params) {
  var data = fromData(params)
  return request({
    url: '/connect/addConnect',
    method: 'post',
    data
  })
}

// 编辑连接
export function editConnect (params) {
  var data = fromData(params)
  return request({
    url: '/connect/editConnect',
    method: 'post',
    data
  })
}

// 删除连接
export function delConnect (params) {
  var data = fromData(params)
  return request({
    url: '/connect/del_connect',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
